# -*- coding: utf-8 -*-

###########################################################################
#
#   Copyright (c) 2020  Bresee, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################

# 获取数据:用户数据
#  get databoard : user data

from flask import Blueprint
from flask import request
import utils.common.httpclient as httpclient
import json
from utils.wraps import token, urlcost
import utils.message.response as response

operat_module = Blueprint('dataBoard_operat', __name__,
                          url_prefix='/api/v1/dataBoard')

"""
input :
{
    "caseId":"1",                      
    "begin_date":"2022-02-28" ,        
    "end_date":"2022-03-06"           
   
}
"""

"""
output :
{
    "ref_date":"20220228-20220306",    
    "caseId":"1",                      
    "activeUsers":{
        "totalCount": 100,             
        "dayInfo":[
            
        ]
    },
    "downLoadUsers":{
        "totalCount":100,              
        "dayInfo":[
            {"userCount":10,"time":"2022-02-28"},
            {"userCount":20,"time":"2022-03-01"},
            {"userCount":15,"time":"2022-03-02"},
            {"userCount":25,"time":"2022-03-03"},
            {"userCount":25,"time":"2022-03-04"},
            {"userCount":25,"time":"2022-03-05"},
            {"userCount":25,"time":"2022-03-06"}       
        ]
    },
    "payUsers":{
        "totalCount":50,              
        "dayInfo":[
            {"userCount":10,"time":"20220228"},
            {"userCount":20,"time":"20220301"},
            {"userCount":15,"time":"20220302"},
            {"userCount":25,"time":"20220303"},
            {"userCount":25,"time":"20220304"},
            {"userCount":25,"time":"20220305"},
            {"userCount":25,"time":"20220306"}       
        ]
    },
    "payVideos":{                      
        "totalCount":150,
        dayInfo:[
            {"videoCount":10,"time":"20220228"},
            {"videoCount":20,"time":"20220301"},
            {"videoCount":15,"time":"20220302"},
            {"videoCount":25,"time":"20220303"},
            {"videoCount":25,"time":"20220304"},
            {"videoCount":25,"time":"20220305"},
            {"videoCount":25,"time":"20220306"}   
        ]
    },
    "composeUsers":{
        "totalCount":100,              
        "dayInfo":[
            {"userCount":10,"time":"20220228"},
            {"userCount":20,"time":"20220301"},
            {"userCount":15,"time":"20220302"},
            {"userCount":25,"time":"20220303"},
            {"userCount":25,"time":"20220304"},
            {"userCount":25,"time":"20220305"},
            {"userCount":25,"time":"20220306"}       
        ]
    },
   "composeVideos":{
        "totalCount":100,              
        "dayInfo":[
            {"videoCount":10,"time":"20220228"},
            {"videoCount":20,"time":"20220301"},
            {"videoCount":15,"time":"20220302"},
            {"videoCount":25,"time":"20220303"},
            {"videoCount":25,"time":"20220304"},
            {"videoCount":25,"time":"20220305"},
            {"videoCount":25,"time":"20220306"}       
        ]
    },
    "shareUsers":{
        "totalCount":100,              
        "dayInfo":[
            {"userCount":10,"time":"20220228"},
            {"userCount":20,"time":"20220301"},
            {"userCount":15,"time":"20220302"},
            {"userCount":25,"time":"20220303"},
            {"userCount":25,"time":"20220304"},
            {"userCount":25,"time":"20220305"},
            {"userCount":25,"time":"20220306"}       
        ]
    },
    "shareClick":{
        "totalCount":200,                 
        "dayInfo":[
            {"clickCount":10,"time":"20220228"},
            {"clickCount":20,"time":"20220301"},
            {"clickCount":15,"time":"20220302"},
            {"clickCount":25,"time":"20220303"},
            {"clickCount":25,"time":"20220304"},
            {"clickCount":25,"time":"20220305"},
            {"clickCount":25,"time":"20220306"}       
        ]  
    },
    "playClick":{                       
        "totalCount":200,                  
        "dayInfo":[
            {"clickCount":10,"time":"20220228"},
            {"clickCount":20,"time":"20220301"},
            {"clickCount":15,"time":"20220302"},
            {"clickCount":25,"time":"20220303"},
            {"clickCount":25,"time":"20220304"},
            {"clickCount":25,"time":"20220305"},
            {"clickCount":25,"time":"20220306"}       
        ]
    }        
}
"""


@operat_module.route('/getuserdata', methods=['POST'])
def get_databoard():
    dic = json.loads(request.data)
    print('getuserdata input : {}'.format(dic))
    ret = httpclient.post_databoard(dic)
    print('getuserdata output : {}'.format(ret))
    
    return response.make_response_success_tech(ret)
